package com.ruoyi.web.controller.basedata;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.basedata.domain.TerminalsXbView;
import com.ruoyi.basedata.service.ITerminalsXbViewService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 小表档案数据视图Controller
 *
 * @author gdqt
 * @date 2024-03-19
 */
@RestController
@RequestMapping("/basedata/terminalsXbView")
public class TerminalsXbViewController extends BaseController {
    @Autowired
    private ITerminalsXbViewService terminalsXbViewService;

    /**
     * 查询小表档案数据视图列表
     */
    @PreAuthorize("@ss.hasAnyPermi('basedata:terminalsXbView:list,basedata:meterSheets:list')")
    @GetMapping("/list")
    public TableDataInfo list(TerminalsXbView terminalsXbView) {
        startPage();
        List<TerminalsXbView> list = terminalsXbViewService.selectTerminalsXbViewList(terminalsXbView);
        return getDataTable(list);
    }

    /**
     * 查询小表档案数据视图列表
     */
    @PreAuthorize("@ss.hasAnyPermi('basedata:terminalsXbView:list,basedata:meterSheets:list')")
    @GetMapping("/getTerminalsXbViewData")
    public AjaxResult getTerminalsXbViewData(TerminalsXbView terminalsXbView) {
        TerminalsXbView terminalsXbViewData = terminalsXbViewService.getTerminalsXbViewData(terminalsXbView);
        return success(terminalsXbViewData);
    }

    /**
     * 导出小表档案数据视图列表
     */
    @PreAuthorize("@ss.hasPermi('basedata:terminalsXbView:export')")
    @Log(title = "小表档案数据视图", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TerminalsXbView terminalsXbView) {
        List<TerminalsXbView> list = terminalsXbViewService.selectTerminalsXbViewList(terminalsXbView);
        ExcelUtil<TerminalsXbView> util = new ExcelUtil<TerminalsXbView>(TerminalsXbView.class);
        util.exportExcel(response, list, "小表档案数据视图数据");
    }

    /**
     * 获取小表档案数据视图详细信息
     */
    @PreAuthorize("@ss.hasPermi('basedata:terminalsXbView:query')")
    @GetMapping(value = "/{tenantId}")
    public AjaxResult getInfo(@PathVariable("tenantId") String tenantId) {
        return success(terminalsXbViewService.selectTerminalsXbViewByTenantId(tenantId));
    }

    /**
     * 新增小表档案数据视图
     */
    @PreAuthorize("@ss.hasPermi('basedata:terminalsXbView:add')")
    @Log(title = "小表档案数据视图", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TerminalsXbView terminalsXbView) {
        return toAjax(terminalsXbViewService.insertTerminalsXbView(terminalsXbView));
    }

    /**
     * 修改小表档案数据视图
     */
    @PreAuthorize("@ss.hasPermi('basedata:terminalsXbView:edit')")
    @Log(title = "小表档案数据视图", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TerminalsXbView terminalsXbView) {
        return toAjax(terminalsXbViewService.updateTerminalsXbView(terminalsXbView));
    }

    /**
     * 删除小表档案数据视图
     */
    @PreAuthorize("@ss.hasPermi('basedata:terminalsXbView:remove')")
    @Log(title = "小表档案数据视图", businessType = BusinessType.DELETE)
    @DeleteMapping("/{tenantIds}")
    public AjaxResult remove(@PathVariable String[] tenantIds) {
        return toAjax(terminalsXbViewService.deleteTerminalsXbViewByTenantIds(tenantIds));
    }
}
